const Sequelize = require("sequelize");
const mysqlConfig = require('../../config').mysql;
const tables = require('./upgrade/tables');

const sequelize = new Sequelize(mysqlConfig.dbname, mysqlConfig.username, mysqlConfig.password, mysqlConfig.connection);
for (let name in tables) {
    let model = tables[name];
    sequelize.define(name, model, {
        createdAt: 'created_at', updatedAt: 'updated_at', timestamps: true, underscored: true
    });
}
sequelize.sync().then(function () {
    console.log('Create tables has been successfully.');
});